#include <iostream>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
#include <signal.h>
#define PATHNAME "./fifo"

void handler(int sig)
{
    std::cout << "receive signal : " << sig << std::endl;
    exit(1);
}
int main()
{
    for(int i =1 ;i<32;i++)
        signal(i,handler);
    // 打开管道文件
    int wfd = open(PATHNAME, O_WRONLY);
    // 写入
    const char *msg = "abcd";
    while (true)
    {
        write(wfd, msg, strlen(msg));
        sleep(1);
        std::cout << "write : " << msg << std::endl;
    }
    return 0;
}